package vip.xiaonuo.sys.fymodule.thirdpa.api.impl;

import com.alibaba.fastjson.JSONObject;
import vip.xiaonuo.sys.config.TaskExecutePoolConfig;
import vip.xiaonuo.sys.core.util.PaPayUtil;
import vip.xiaonuo.sys.fymodule.account.service.ISxoSafetyLogService;
import vip.xiaonuo.sys.fymodule.thirdpa.api.BaseClient;

/**
 * 会员解绑提现账户(KFEJZB6065)
 */
public class UnbindRelateAcctApi extends BaseClient {

    private final ISxoSafetyLogService sxoSafetyLogService;
    private final TaskExecutePoolConfig taskExecutePoolConfig;

    public UnbindRelateAcctApi(ISxoSafetyLogService sxoSafetyLogService, TaskExecutePoolConfig taskExecutePoolConfig){
        this.sxoSafetyLogService=sxoSafetyLogService;
        this.taskExecutePoolConfig=taskExecutePoolConfig;
    }

    @Override
    public String getApiUrl() {
        return PaPayUtil.UNBIND_RELATE_ACCT;
    }

    @Override
    public void saveResult(String logId, String result) {
        taskExecutePoolConfig.getAsyncExecutor().execute(() -> {
            sxoSafetyLogService.updateSafetyLog(logId, result);
        });
    }

    @Override
    public String saveLog(JSONObject params) {
        String busId = params.getString("MemberAcctNo");
        return sxoSafetyLogService.saveSafetyLog("", busId, PaPayUtil.UNBIND_RELATE_ACCT, params.toJSONString());
    }

}
